package secondaryTable;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;


public class TwoTableTest {
	SessionFactory sessionFactory;
	
	@BeforeClass
	public void setup(){
		Configuration cfg = new Configuration();
		cfg.configure();
		StandardServiceRegistryBuilder srvBuilder = new StandardServiceRegistryBuilder();
		srvBuilder.applySettings(cfg.getProperties());
		sessionFactory = cfg.buildSessionFactory(srvBuilder.build());
	}
	@Test
	public void twotableTest(){
		Customer customer = new Customer();
		customer.name = "hibernate";
		customer.address = "hibernate.org";
		Session session = sessionFactory.openSession();
		Transaction txn = session.beginTransaction();
		session.save(customer);
		txn.commit();
		session.close();
	}

}
